Skip to content

Both Readers : Read a line back, and write one that runs right to left the right way round - #988

Open
dkulyk wants to merge 1 commit into
PHPOffice:masterfrom
sapientpro:fix/reader-line
Open

Both Readers : Read a line back, and write one that runs right to left the right way round#988
dkulyk wants to merge 1 commit into
PHPOffice:masterfrom
sapientpro:fix/reader-line

Conversation

@dkulyk

@dkulyk dkulyk commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Description

Both Writers write a Line and neither Reader read one back, so a deck that was loaded and saved again lost every line it had. Reader/PowerPoint2007::loadSlideShapes() switches on the tag name and had no p:cxnSp arm; Reader/ODPresentation::loadSlide() walked draw:frame only, and a draw:line is a shape of the page rather than the content of a frame.

Measuring the round trip turned up a second defect, in the Writer, which had to go with it. An OOXML extent cannot be negative, so a line whose end is behind its start is written from the other end with flipH / flipV saying which axis it is mirrored on. writeShapeLine() wrote flipV for a line that runs right to left, and nothing at all for one that runs up and to the left:

line written before written now
down and to the right no flip no flip
up and to the right flipV flipV
down and to the left flipV flipH
up and to the left nothing flipH and flipV

So a line drawn right to left arrived mirrored in PowerPoint, with no reader involved. PptSlidesTest::testLine created all four lines but asserted only that some a:xfrm carried a flipV, which the second case satisfies on its own, so nothing caught it. That test now says which of the three forms it expects, and the two readers each round-trip a line in all four directions.

The ODPresentation Writer needed nothing: ODF says a line by the two points it runs between, so a negative width is simply an svg:x2 smaller than the svg:x1.

Fixes #987

Checklist:

  • I have run composer run-script check --timeout=0 and no errors were reported

phpunit, phpstan, phpmd and php-cs-fixer all clean.

  • The new code is covered by unit tests (check build & code coverage report)

testLineSurvivesTheRoundTrip in both Reader tests, over the four directions a line can run, and the three flip forms asserted in PptSlidesTest::testLine.

Nothing to describe: createLineShape() is documented already and its behaviour is unchanged.

  • I have added an entry in the CHANGELOG.md file

Under Bug fixes.

@coveralls

coveralls commented Sep 3, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 94.131% (+0.02%) from 94.111% — sapientpro:fix/reader-line into PHPOffice:master

@dkulyk
dkulyk force-pushed the fix/reader-line branch 4 times, most recently from ddb2db2 to 6761941 Compare September 8, 2026 08:54
…t the right way round

Both Writers write a `Line` and neither Reader read one, so a deck that was loaded and saved again
lost every line it had. `loadSlideShapes()` in the PowerPoint2007 Reader switches on the tag name
and had no `p:cxnSp` arm; the ODPresentation Reader walks `draw:frame` only, and a `draw:line` is a
shape of the page in its own right rather than the content of a frame.

Measuring the round trip turned up a second defect, in the Writer, which had to go with it. An OOXML
extent cannot be negative, so a line whose end is behind its start is written from the other end
with `flipH` or `flipV` saying which axis it is mirrored on. `writeShapeLine()` wrote `flipV` for a
line that runs right to left, and nothing at all for one that runs up and to the left, so both
arrived mirrored in PowerPoint with no reader involved. `PptSlidesTest::testLine` created all four
lines but asserted only that some `a:xfrm` carried a `flipV`, which the line running up and to the
right satisfies on its own.

The ODPresentation Writer needed nothing: ODF says a line by the two points it runs between, so a
negative width is an `svg:x2` smaller than the `svg:x1`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

PowerPoint2007 and ODPresentation Readers : a line is written by both Writers and read back by neither

2 participants